﻿using System.Threading;

namespace Bookvar.UI
{
    internal static class Singleton<T> where T : new()
    {
        private static readonly Mutex mutex = new Mutex();
        private static T instance;

        public static T Instance
        {
            get
            {
                mutex.WaitOne();
                if(instance == null)
                {
                    instance = new T();
                }
                mutex.ReleaseMutex();
                return instance;
            }
        }
    }
}
